package com.baofu.paycore.service.processor.consume;

import com.baofu.paycore.manager.model.PayBO;
import com.baofu.paycore.service.converter.DTO2BOConverter;
import com.baofu.paycore.service.facade.model.pay.PayDTO;
import com.baofu.paycore.service.processor.PayBaseProcessor;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

/**
 * 支付主单处理类
 *
 * <p/>
 *      1、构建支付属性
 * </p>
 * User: LZQ Date: 2016/04/20  Version: 1.0
 */
@Component
public class ConsumeProcessor implements PayBaseProcessor<PayBO, PayDTO> {

    /**
     * 构建支付属性
     *
     * @param payBO      支付模型
     * @param payDTO     请求参数
     */
    @Override
    public PayBaseProcessor process(PayBO payBO, PayDTO payDTO) {

        DTO2BOConverter.payBaseBOConverter(payDTO, payBO);
        if(!CollectionUtils.isEmpty(payDTO.getPaymentExt())){
            payBO.setPaymentExt(payDTO.getPaymentExt());
        }
        DTO2BOConverter.payDTOToBO(payDTO, payBO);
        return this;
    }
}
